"""
    员工管理业务接口层
"""
# 导包
import requests
from common.get_header import get_header

class EmployeeManagerAPi:
    # 新增员工
    @classmethod
    def add_employee(cls,json_data,header):
        employee_add_url = "http://localhost:8080/admin/employee"
        # 发送post请求
        resp = requests.post(url=employee_add_url,headers=header,json=json_data)
        return resp
    # 查询员工
    @classmethod
    def query_employee(cls,emp_id,header):
        employee_query_url = "http://localhost:8080/admin/employee/"+str(emp_id)
        # 发送get请求
        resp = requests.get(url=employee_query_url,headers=header)
        return resp

    # 修改员工
    @classmethod
    def update_employee(cls,data,header):
        employee_update_url = "http://localhost:8080/admin/employee"
        # 发送put请求
        resp = requests.put(url=employee_update_url,headers=header,json=data)
        # 返回响应结果
        return resp
    # 查询员工列表
    @classmethod
    def query_emp_list(cls,page,pageSize,haader):
        list_url = "http://localhost:8080/admin/employee/page"
        params = {
            "page": str(page),  # 转换为字符串
            "pageSize": str(pageSize)
        }
        resp = requests.get(url=list_url,params=params,headers=haader)
        return resp




if __name__ == '__main__':
        json_data = {"id": 27,
                  "idNumber": "120101190001011932",
                  "name": "冯保",
                  "phone": "1342856320",
                  "sex": "1",
                  "username": "fengbao" }
        print(EmployeeManagerAPi.add_employee(json_data).json())